//
//  MqManagerHandle.m
//  Meiqi
//
//  Created by lanou on 16/1/20.
//  Copyright © 2016年 KFC. All rights reserved.
//

#import "MqManagerHandle.h"

@implementation MqManagerHandle

//  单例类初始化
+ (instancetype)sharedManager{
    
    static MqManagerHandle *handle = nil;
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        
        handle = [[MqManagerHandle alloc] init];
        
    });
    
    return handle;
    
}

- (instancetype)init{
    
    self = [super init];
    
    if (self) {
        
        _historyArray = [NSMutableArray array];

    }
    
    return self;

}

//  增加历史记录
- (void)addHistoryObjectWith:(MqForumModule *)module{
    
    //  遍历数组查找是否有相同的
    for (int i = 0; i < _historyArray.count; i++) {
    
        
        if (module == _historyArray[i]) {
            
            //  相同的删除
            [_historyArray removeObject:_historyArray[i]];
            
        }
        
    }
    
    if (_historyArray.count == 5) {
        
        [_historyArray removeObjectAtIndex:4];
        
    }
    [_historyArray insertObject:module atIndex:0];
}









@end
